package com.wuseguang.springcloud.service.impl;

import com.wuseguang.springcloud.dao.jdbc.MeMoralEducationJdbc;
import com.wuseguang.springcloud.dao.repository.MeMoralEducationRepository;
import com.wuseguang.springcloud.entity.MeMoralEducation;
import com.wuseguang.springcloud.service.MeMoralEducationService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 德育-德育项 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-06-28
 */
@Service
public class MeMoralEducationServiceImpl  implements MeMoralEducationService {


    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private MeMoralEducationJdbc meMoralEducationJdbc;
    @Autowired
    private MeMoralEducationRepository meMoralEducationRepository;

    @Override
    public Result addMoraleEducation(MeMoralEducation meMoralEducation) {
        logger.info("添加班级德育项");
        meMoralEducation.setAddTime(new Date());
        meMoralEducationRepository.save(meMoralEducation);
        return new Result();
    }

    @Override
    public Result findMoraleEducation(String schoolId) {
        logger.info("查询班级德育项");
         List<MeMoralEducation> list =  meMoralEducationRepository.findBySchoolId(Integer.valueOf(schoolId));
        return new Result(list);
    }

    @Override
    public Result deleteMoraleEducation(Integer id) {
        logger.info("删除班级德育项");
        meMoralEducationRepository.deleteById(id);
        return new Result();
    }
}
